Skip to main content

getUnapprovedProvidersRatings

getUnapprovedProvidersRatings

This method fetches paginated, unapproved provider ratings with optional filtering by business location and/or agent.

  1. Initialize Pagination Parameters

    • Normalize page and limit values to ensure they are at least 1 and 10 respectively.
    • Calculate skip value for pagination offset based on the current page and limit.
  2. Build Database Query

    • Start query on ratingAppointmentRepo targeting ratings with status "pending".

    • Join related entities:

      • Customer
      • Business Location
      • Agent and Agent Type
      • Appointment (including EHR appointment data)
    • Apply filters if provided:

      • Filter by businessLocationId if given.
      • Filter by agentId if given.
  3. Define Fields to Select

    • Select detailed rating fields (overall, provider, staff, clinic ratings, comments, etc.).
    • Select customer details (ID, decrypted names, gender identity).
    • Select appointment identifiers and start times (both internal and external).
    • Select business location details.
    • Select agent details including agent type.
  4. Execute Query with Pagination

    • Apply .skip(skip) and .take(limit) to paginate results.
    • Fetch raw data rows.
    • Fetch total count of matching records (for pagination metadata).
  5. Map Raw Data to Structured DTOs

    • For each raw record:

      • Construct a rating object including nested customer, appointment, business location, and agent data.
      • Decrypt customer first and last names.
  6. Build and Return Response

    • Compose the response object with:

      • data: list of mapped rating DTOs.
      • pagination: object containing total records, current page, limit, and total pages.